import { reactive } from "vue";
import axios, { AxiosError } from 'axios';

export default function() {
    
    let dogs = reactive<string[]>([])

    async function getDog() {
        try{
            let {data} = await axios.get('https://dog.ceo/api/breed/pembroke/images/random')
            dogs.push(data.message)
        } catch(error) {
            // 处理错误
            const err = <AxiosError>error
            console.log(err.message)
        }
    }

    return {dogs, getDog}
}